package zhoufu.sz.sanxiao_check.models;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * User:RCP
 * email:ruancaipu@gmail.com
 * Date:2016/8/5
 */
public class CheckBook implements Parcelable
{
    public String name;

    public String Place_ID;

    public String checkDate;

    public String completeDate;

    public String item_unComplete;

    public String item_complete;

    public String path;


    public CheckBook(CheckItemModel item)
    {
        name = item.getName() + "(地址：" + item.getAddress() + ")";
        checkDate = item.getAddTime();
        completeDate = item.getComplete_Time();
        Place_ID = item.getPlace_No();
        StringBuffer sb1 = new StringBuffer();
        StringBuffer sb2 = new StringBuffer();
        for (DangerModel dangerModel : item.getDangers())
        {
            if ( dangerModel.getIs_Ok() != 1 )
            {
                continue;
            }
            if ( dangerModel.getDisposeStatus() == 0 )//未整改
            {
                sb1.append(dangerModel.getContent() + "(" + dangerModel.getMeasure() + ")" + "-");
            } else
            {
                sb2.append(dangerModel.getContent() + "(" + dangerModel.getMeasure() + ")" + "-");
            }
        }
        if ( sb1.length() == 0 )
        {
            item_unComplete = "无";
        } else
        {
            item_unComplete = sb1.toString();
        }
        if ( sb2.length() == 0 )
        {
            item_complete = "无";
        } else
        {
            item_complete = sb2.toString();
        }
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    protected CheckBook(Parcel in)
    {
        name = in.readString();
        Place_ID = in.readString();
        checkDate = in.readString();
        completeDate = in.readString();
        item_unComplete = in.readString();
        item_complete = in.readString();
    }

    public static final Creator<CheckBook> CREATOR = new Creator<CheckBook>()
    {
        @Override
        public CheckBook createFromParcel(Parcel in)
        {
            return new CheckBook(in);
        }

        @Override
        public CheckBook[] newArray(int size)
        {
            return new CheckBook[size];
        }
    };

    @Override public int describeContents()
    {
        return 0;
    }

    @Override public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeString(name);
        dest.writeString(Place_ID);
        dest.writeString(checkDate);
        dest.writeString(completeDate);
        dest.writeString(item_unComplete);
        dest.writeString(item_complete);
    }
}
